<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-CN" />
<meta name="author" content="tis-tis" />
<link href="{$tpl_path}/adminstyle.css" type=text/css rel=stylesheet />
{popup_init src="../js/common.js"}
<title>{$title}</title>
</head>
<body>
<!-- 头部 -->
<div class="adminbox">{include file="header.tpl"} <!-- 左边工具条-->
<div class="mainbox">{include file="sidebar.tpl"} <!-- 右边内容部分，即可变部分 -->
<div class="contentbox">
<form name="form1" method="post" action="image_admin.php"
	enctype="multipart/form-data" onsubmit="return validate()">
<div class="item">
<div class="tag">是否为广告位：</div>
<select name="is_ad" onchange='setIsAdd(this.value)'>
	<option value='0'>否</option>
	<option value='1'>是</option>
</select></div>
<div class="item">
<div class="tag">上传图片：</div>
<input type="file" name="img_info" size="35" /></div>
<div id="ISADD" class="hidden">
<div class="item">
<div class="tag">图片源址：</div>
<input type="input" name="img_info_src" size="35" value="http://" /></div>
<div class="item">
<div class="tag">广告链接：</div>
<input type="input" name="img_info_url" size="35" /></div>
<div class="item">
<div class="tag">是否打开新窗口：</div>
<select name="is_open_new">
	<option value='0'>否</option>
	<option value='1'>是</option>
</select></div>
<div class="item">
<div class="tag">广告描述：</div>
<textarea maxlength="255" name="img_info_des" cols="60" rows="4"></textarea></div>
</div>
<div align="center"><input type="hidden" name="act"
	value="{$form_action}" /> <input type="submit" value="提交" /> <input
	type="reset" value="重置" /></div>

</form>
</div>
</div>
</div>
{literal}
<script language="javascript">
/**
 * 当选择是添加广告位的时候做出处理。
 */
function setIsAdd(value) {
	var doc = document.getElementById('ISADD');
	
	if (value == 0) {
		doc.className = 'hidden';
	} else {
		doc.className = 'show';
	}
}

function validate() {
	var form = document.forms['form1'];
	var value = form.elements['is_ad'].value;
	var result = '';

	if (value == 0) {
		value = form.elements['img_info'].value;
		if (value == null || trim(value) == '') {
			result += "没有上传图片，请上传图片！\n";
		}
	} else {
		value = form.elements['img_info'].value;
		var value1 = form.elements['img_info_src'].value;
		var flat = (value == null || trim(value) == '');
		var flat1 = (value1 == null || trim(value1) == '' || trim(value1) == 'http://');
			
		if (flat && flat1) {
			result += "当前的广告位没有图片，请上传图片或者填写图片的源地址！\n";
		}

		value = form.elements['img_info_url'].value;
		if (value == null || trim(value) == '') {
			result += "广告链接不能为空！\n";
		}
	}

	if (result != '') {
		alert(result);
		return false;
	}

	return true;
}

</script>
{/literal}
</body>
</html>
